package com.example.flow.dao.impl;


import com.example.flow.dao.FlowTaskHisDao;
import com.example.flow.dao.mapper.FlowTaskHisMapper;
import com.example.flow.dao.model.FlowProcessExt;
import com.example.flow.dao.model.FlowTaskHis;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.BaseMapper;

/**
 * @author tangaq
 * 2023/6/15
 */
@Repository
public class RdsFlowTaskHisDaoImpl implements FlowTaskHisDao {
    private final FlowTaskHisMapper historyTaskMapper;

    public RdsFlowTaskHisDaoImpl(FlowTaskHisMapper historyTaskMapper) {
        this.historyTaskMapper = historyTaskMapper;
    }

    @Override
    public FlowTaskHis findByTaskId(String taskId) {
        if (StringUtils.isBlank(taskId)) {
            return null;
        }

        FlowTaskHis flowTaskHis = new FlowTaskHis();
        flowTaskHis.setTaskId(taskId);
        return historyTaskMapper.selectOne(flowTaskHis);
    }

    @Override
    public void deleteByOrderId(String orderId) {
        if (StringUtils.isBlank(orderId)) {
            return;
        }
        FlowTaskHis flowTaskHis = new FlowTaskHis();
        flowTaskHis.setOrderId(orderId);
        historyTaskMapper.delete(flowTaskHis);
    }

    @Override
    public void insert(FlowTaskHis history) {
        historyTaskMapper.insert(history);
    }
}
